﻿<?php
define('IN_QY',true);
session_start();
require("include/common.inc.php");
require('include/functions.php');
define('SCRIPT','ad_list');
if(!$_COOKIE['userid']){
	echo "<script type='text/javascript'>location.href='mlogin.php';</script>";
	exit;
}
$sqlu = "select * from tbl_user where id=".$_COOKIE['userid'];
$queryu=mysql_query($sqlu);
$rowu=mysql_fetch_array($queryu);
if($_GET['act']=='login'){
	$name=trim($_POST['name']);
	$tell=trim($_POST['tell']);
	$dizhi=$_POST['dizhi'];

    $diqu=$_POST['diqu'];
	$diqu1=explode(",", $diqu);
    $diqu2=$diqu1[0];
	
$sqlc = "select * from tbl_province where proname='".$diqu2."'";
$queryc=mysql_query($sqlc);
$rowc=mysql_fetch_array($queryc);		
	$diz=$_POST['diz'];	
	$sql = "insert into
	 tbl_address
	  values (
	  	0,
	  	'".$name."',
	  	'".$tell."',
	  	'".$_COOKIE['userid']."',
	  	'".$dizhi."',
		'".$rowc['id']."',
		'".$diqu1[2]."',
		0,
		'".$diqu1[0]."',
		'".$diqu1[1]."'		
		)";
	mysql_query($sql);
	echo "<script type='text/javascript'>alert('\u63d0\u4ea4\u6210\u529f');location.href='myaddress.php?diz=".$diz."';</script>";
}
	//2222222222222222
?>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title><?=$_COOKIE['shuyu']?>/新增地址-众晒网</title>
    <link href="/ui/css/Hui.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
     #header{width:100%; position:absolute; top:0;}
     #footer{width:100%; height:55px; position:absolute; bottom:0;}	 
     #main{width:100%; overflow: auto; position:absolute; top:45px;bottom:0px;}
     table{background-color:white;margin:10px;width: 95%;}

    </style>
    <script src="/ui/js/jquery.min.js"></script>
</head>
<body>
    <header class="H-header H-theme-background-color-white" id="header">
        <span tapmode="" onclick="H.closeWin();" class="H-icon H-position-relative H-display-inline-block H-float-left H-vertical-middle H-theme-font-color-white H-padding-horizontal-left-10 H-z-index-100"><i class="H-iconfont H-icon-arrow-left H-theme-font-color-black H-font-size-18 H-vertical-middle"></i></span>
        <div class="H-header-title H-center-all H-font-size-18 H-text-show-row-1 H-theme-font-color-black H-position-absolute H-width-100-percent H-font-weight-500">新增地址</div>
    </header>
    <div id="main">
<form  action="?act=login"   id="signupok" method="post" name="addform"  onSubmit="return beforeSubmit(this);">
	 <div class="H-padding-vertical-bottom-10"></div>
     <div >
        <div class="H-flexbox-horizontal ">
     <div class="H-border-vertical-both-after" style="width:96%;margin:7px">
        <div class="H-flexbox-horizontal H-border-vertical-bottom-margin-left-10-after">
            <span class="H-vertical-middle H-padding-horizontal-left-10 H-theme-background-color-white H-font-size-16">您的姓名:</span><input type="text"  name="name"  class="H-textbox H-vertical-align-middle H-vertical-middle H-font-size-15 H-flex-item H-box-sizing-border-box H-border-none H-outline-none H-padding-12" placeholder="您的姓名" />
        </div>
        <div class="H-flexbox-horizontal H-border-vertical-bottom-margin-left-10-after">
            <span class="H-vertical-middle H-padding-horizontal-left-10 H-theme-background-color-white H-font-size-16">手机号码:</span><input type="text"  name="tell"   placeholder="您的收货手机号码" class="H-textbox H-vertical-align-middle H-vertical-middle H-font-size-15 H-flex-item H-box-sizing-border-box H-border-none H-outline-none H-padding-12"/>
        </div>
			
		<div  class="H-padding-10 H-border-vertical-bottom-after  H-theme-background-color-white H-flexbox-horizontal H-theme-font-color-999 H-font-size-14 H-flexbox-horizontal H-text-horizontal-left H-box-sizing-border-box H-margin-vertical-bottom-5" > 

        <span class="H-display-block H-flex-item H-theme-font-color-black-active" style="line-height:20px">
         <span>请选择所在地区</span> <span style="float:right;color:#EE7942;">
            <input id="demo1" type="text"  name="diqu"  readonly="" placeholder="请选择所在地区"  value=""/>
			</span>
                 </span>
           </div>			
			
        <div class="H-flexbox-horizontal H-border-vertical-bottom-margin-left-10-after">
            <span class="H-vertical-middle H-padding-horizontal-left-10 H-theme-background-color-white H-font-size-16">详细地址:</span><input type="text"  name="dizhi"  placeholder="请输入详细的地址信息" class="H-textbox H-vertical-align-middle H-vertical-middle H-font-size-15 H-flex-item H-box-sizing-border-box H-border-none H-outline-none H-padding-12"/>
        </div>  
		
	          <input  type="hidden"  name="diz"  readonly="" placeholder="请选择所在地区"  value="<?=$_GET['diz']?>"/>
		
<div class="Validform_checktip"></div>
    </div>
        </div>
    </div>


       <div style="margin-top:20px">
    <center>
    <button type="submit" name="signup" class="H-button H-width-100-percent H-padding-vertical-both-8 H-font-size-18 H-outline-none H-padding-horizontal-both-17 H-theme-background-color8 H-theme-font-color-white H-theme-border-color8 H-theme-border-color8-click H-theme-background-color8-click H-theme-font-color8-click H-border-radius-3" style="width:70%">确认提交</button>
    </center>
        </div>
</form>		
    </div>

     <!--################################底部开始################################-->  	
    <?include('footer.php');?>
     <!--################################底部结束################################-->
    <script src="/ui/script/H.js" type="text/javascript"></script>
	<script type="text/javascript">
function beforeSubmit(form){
    if (document.addform.name.value==""){
        alert('请输入姓名');
        document.addform.name.focus();
        return false;
    }
    if (document.addform.tell.value==""){
        alert('请输入手机号码');
        document.addform.tell.focus();
        return false;
     }
   
    if (document.addform.diqu.value==""){
        alert('请输入地区');
        document.addform.diqu.focus();
        return false;
    }
	    if (document.addform.dizhi .value==""){
        alert('请输入详细地址');
        document.addform.dizhi .focus();
        return false;
    }

var reg = /^(\w)+(\.\w+)*@(\w)+((\.\w{2,3}){1,3})$/;;
var yx=document.addform.email.value;
   if (document.addform.email.value==""){
        alert('邮箱不能为空！');
        document.addform.email.focus();
        return false;
    }
    if(!reg.test(yx)){
    	alert('邮箱错误');
    	document.addform.email.focus();
        return false;
    }


    mui("#input_example input").each(function() {
//若当前input为空，则alert提醒 
		if(!this.value || this.value.trim() == "") {
		    var label = this.previousElementSibling;
		    mui.alert(label.innerText + "不允许为空");
		    check = false;
		    return false;
		}
	}); //校验通过，继续执行业务逻辑 
	if(check){
	    mui.alert('验证通过!')
	}

    document.addform.submit();
    return true;  
}
</script>
    <script>
        $(function() {  
  
    var tel = $('#tel').html();  
  
    var mtel = tel.substr(0, 3) + '****' + tel.substr(7);  
    $('#tel').text(mtel); 
   /* var tel = $('#tel').html();
    alert(tel);
    var mtel=tel.split('');
    var mmtel=mtel.splice(3,4,"****");
    var mmmtel=mtel.join('');
    alert("mtel:"+mtel);
    alert("mmtel:"+mmtel);
    alert("mmmtel:"+mmmtel);
     $('#tel').text(mmmtel);*/
}); 
    </script>
	    <link rel="stylesheet" href="sanji/css/LArea.css">
    <script src="sanji/js/LAreaData1.js"></script>
    <script src="sanji/js/LAreaData2.js"></script>
    <script src="sanji/js/LArea.js"></script>
	
    <script>
    var area1 = new LArea();
    area1.init({
        'trigger': '#demo1', //触发选择控件的文本框，同时选择完毕后name属性输出到该位置
        'valueTo': '#value1', //选择完毕后id属性输出到该位置
        'keys': {
            id: 'id',
            name: 'name'
        }, //绑定数据源相关字段 id对应valueTo的value属性输出 name对应trigger的value属性输出
        'type': 1, //数据源类型
        'data': LAreaData //数据源
    });
    area1.value=[26,262,3210];//控制初始位置，注意：该方法并不会影响到input的value
    var area2 = new LArea();
    area2.init({
        'trigger': '#demo2',
        'valueTo': '#value2',
        'keys': {
            id: 'value',
            name: 'text'
        },
        'type': 2,
        'data': [provs_data, citys_data, dists_data]
    });
    </script>	
</body>
</html>